hu Feb 26 15:43:43 2004 Owen Taylor <otaylor@redhat.com>
authorOwen Taylor <otaylor@src.gnome.org>
Thu, 26 Feb 2004 20:59:01 +0000 (20:59 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Thu, 26 Feb 2004 20:59:01 +0000 (20:59 +0000)
        * gtk/gtkstyle.[ch]: Export insertion cursor drawing functionality
        in a simplified form as gtk_draw_insertion_cursor().
        (#99031, request from Alex Larsson)

        * gtk/gtktextdisplay.c gtk/gtkentry.c gtk/gtklabel.c:
        Adapt to new gtk_draw_insertion_cursor().

        * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_class_init)
        gtk/gtkstyle.c (gtk_style_class_init): Add some missed
        Since: 2.4.

        * gtk/gtkiconfactory.c (icon_size_settings_changed)
          gtk/gtkicontheme.c (do_theme_change)
          gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
        * gtk/gtksettings.c (gtk_settings_notify):
        _gtk_rc_reset_styles => gtk_rc_reset_styles.

17 files changed:
ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/gtk/gtk-sections.txt
gtk/gtkentry.c
gtk/gtkiconfactory.c
gtk/gtkicontheme.c
gtk/gtklabel.c
gtk/gtkradiobutton.c
gtk/gtkradiomenuitem.c
gtk/gtkrc.c
gtk/gtksettings.c
gtk/gtkstyle.c
gtk/gtkstyle.h
gtk/gtktextdisplay.c

index bfabd0335dc20ef215f6854953a2788e4111e70a..e6d34c2a815921df53043027c3ecff90ea8b188e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,8 +11,6 @@ Thu Feb 26 15:43:43 2004  Owen Taylor  <otaylor@redhat.com>
        gtk/gtkstyle.c (gtk_style_class_init): Add some missed
        Since: 2.4.
 
-Thu Feb 26 15:43:19 2004  Owen Taylor  <otaylor@redhat.com>
-
        * gtk/gtkiconfactory.c (icon_size_settings_changed)
          gtk/gtkicontheme.c (do_theme_change)
          gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
@@ -38,7 +36,6 @@ Thu Feb 26 14:47:22 2004  Dom Lachowicz <cinamod@hotmail.com>
 
        * gtk/gtk.def: Export gtk_rc_reset_styles()
 
->>>>>>> 1.5027
 Thu Feb 26 14:47:22 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkrc.[ch]: Export gtk_rc_reset_styles(). 
index bfabd0335dc20ef215f6854953a2788e4111e70a..e6d34c2a815921df53043027c3ecff90ea8b188e 100644 (file)
@@ -11,8 +11,6 @@ Thu Feb 26 15:43:43 2004  Owen Taylor  <otaylor@redhat.com>
        gtk/gtkstyle.c (gtk_style_class_init): Add some missed
        Since: 2.4.
 
-Thu Feb 26 15:43:19 2004  Owen Taylor  <otaylor@redhat.com>
-
        * gtk/gtkiconfactory.c (icon_size_settings_changed)
          gtk/gtkicontheme.c (do_theme_change)
          gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
@@ -38,7 +36,6 @@ Thu Feb 26 14:47:22 2004  Dom Lachowicz <cinamod@hotmail.com>
 
        * gtk/gtk.def: Export gtk_rc_reset_styles()
 
->>>>>>> 1.5027
 Thu Feb 26 14:47:22 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkrc.[ch]: Export gtk_rc_reset_styles(). 
index bfabd0335dc20ef215f6854953a2788e4111e70a..e6d34c2a815921df53043027c3ecff90ea8b188e 100644 (file)
@@ -11,8 +11,6 @@ Thu Feb 26 15:43:43 2004  Owen Taylor  <otaylor@redhat.com>
        gtk/gtkstyle.c (gtk_style_class_init): Add some missed
        Since: 2.4.
 
-Thu Feb 26 15:43:19 2004  Owen Taylor  <otaylor@redhat.com>
-
        * gtk/gtkiconfactory.c (icon_size_settings_changed)
          gtk/gtkicontheme.c (do_theme_change)
          gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
@@ -38,7 +36,6 @@ Thu Feb 26 14:47:22 2004  Dom Lachowicz <cinamod@hotmail.com>
 
        * gtk/gtk.def: Export gtk_rc_reset_styles()
 
->>>>>>> 1.5027
 Thu Feb 26 14:47:22 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkrc.[ch]: Export gtk_rc_reset_styles(). 
index bfabd0335dc20ef215f6854953a2788e4111e70a..e6d34c2a815921df53043027c3ecff90ea8b188e 100644 (file)
@@ -11,8 +11,6 @@ Thu Feb 26 15:43:43 2004  Owen Taylor  <otaylor@redhat.com>
        gtk/gtkstyle.c (gtk_style_class_init): Add some missed
        Since: 2.4.
 
-Thu Feb 26 15:43:19 2004  Owen Taylor  <otaylor@redhat.com>
-
        * gtk/gtkiconfactory.c (icon_size_settings_changed)
          gtk/gtkicontheme.c (do_theme_change)
          gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
@@ -38,7 +36,6 @@ Thu Feb 26 14:47:22 2004  Dom Lachowicz <cinamod@hotmail.com>
 
        * gtk/gtk.def: Export gtk_rc_reset_styles()
 
->>>>>>> 1.5027
 Thu Feb 26 14:47:22 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkrc.[ch]: Export gtk_rc_reset_styles(). 
index bfabd0335dc20ef215f6854953a2788e4111e70a..e6d34c2a815921df53043027c3ecff90ea8b188e 100644 (file)
@@ -11,8 +11,6 @@ Thu Feb 26 15:43:43 2004  Owen Taylor  <otaylor@redhat.com>
        gtk/gtkstyle.c (gtk_style_class_init): Add some missed
        Since: 2.4.
 
-Thu Feb 26 15:43:19 2004  Owen Taylor  <otaylor@redhat.com>
-
        * gtk/gtkiconfactory.c (icon_size_settings_changed)
          gtk/gtkicontheme.c (do_theme_change)
          gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
@@ -38,7 +36,6 @@ Thu Feb 26 14:47:22 2004  Dom Lachowicz <cinamod@hotmail.com>
 
        * gtk/gtk.def: Export gtk_rc_reset_styles()
 
->>>>>>> 1.5027
 Thu Feb 26 14:47:22 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkrc.[ch]: Export gtk_rc_reset_styles(). 
index 214e78da8c8b6d094720afdf10114f6e9fe93539..05265feef6debfd9ffa6c8d3faa7a614f5b1b3c5 100644 (file)
@@ -4644,6 +4644,7 @@ gtk_paint_vline
 gtk_paint_expander
 gtk_paint_layout
 gtk_paint_resize_grip
+gtk_draw_insertion_cursor
 
 <SUBSECTION>
 GtkBorder
index 394ca2a6a34281187c8c1a3a32c7b89aee15331c..1ea81b337137c4085fe7af41aace7a1bfbf6464c 100644 (file)
@@ -2861,7 +2861,6 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
       GtkTextDirection dir2 = GTK_TEXT_DIR_NONE;
       gint x1 = 0;
       gint x2 = 0;
-      GdkGC *gc;
 
       gdk_drawable_get_size (entry->text_area, NULL, &text_area_height);
       
@@ -2896,20 +2895,16 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
       cursor_location.width = 0;
       cursor_location.height = text_area_height - 2 * INNER_BORDER ;
 
-      gc = _gtk_get_insertion_cursor_gc (widget, TRUE);
-      _gtk_draw_insertion_cursor (widget, entry->text_area, gc,
-                                 &cursor_location, dir1,
-                                  dir2 != GTK_TEXT_DIR_NONE);
-      g_object_unref (gc);
+      gtk_draw_insertion_cursor (widget, entry->text_area, NULL,
+                                &cursor_location, TRUE, dir1,
+                                dir2 != GTK_TEXT_DIR_NONE);
       
       if (dir2 != GTK_TEXT_DIR_NONE)
        {
          cursor_location.x = xoffset + x2;
-         gc = _gtk_get_insertion_cursor_gc (widget, FALSE);
-         _gtk_draw_insertion_cursor (widget, entry->text_area, gc,
-                                     &cursor_location, dir2,
-                                      TRUE);
-         g_object_unref (gc);
+         gtk_draw_insertion_cursor (widget, entry->text_area, NULL,
+                                    &cursor_location, FALSE, dir2,
+                                    TRUE);
        }
     }
 }
index ce5a3c0a2493417fc74bcc9ffa02dfd631d7fb59..b7b5521fa240f25ec5f8d9768d62888836eb67af 100644 (file)
@@ -997,7 +997,7 @@ icon_size_settings_changed (GtkSettings  *settings,
 {
   icon_size_set_all_from_settings (settings);
 
-  _gtk_rc_reset_styles (settings);
+  gtk_rc_reset_styles (settings);
 }
 
 static void
index 994176f397b2d19cb35e32d5edac2be5bf3e3746..f6bc2132b37a61cb2b733fbd6dea9722f2e9552f 100644 (file)
@@ -565,7 +565,7 @@ do_theme_change (GtkIconTheme *icon_theme)
   if (priv->screen && priv->is_screen_singleton)
     {
       GtkSettings *settings = gtk_settings_get_for_screen (priv->screen);
-      _gtk_rc_reset_styles (settings);
+      gtk_rc_reset_styles (settings);
     }
 }
 
index 67399bfc94032c4db7c5e9fb3e6fbbb250e53c59..deb534d32a6aa208da774def2d43d14231fe8b62 100644 (file)
@@ -1723,7 +1723,6 @@ gtk_label_draw_cursor (GtkLabel  *label, gint xoffset, gint yoffset)
       GdkRectangle cursor_location;
       GtkTextDirection dir1 = GTK_TEXT_DIR_NONE;
       GtkTextDirection dir2 = GTK_TEXT_DIR_NONE;
-      GdkGC *gc;
 
       keymap_direction =
        (gdk_keymap_get_direction (gdk_keymap_get_for_display (gtk_widget_get_display (widget))) == PANGO_DIRECTION_LTR) ?
@@ -1766,11 +1765,9 @@ gtk_label_draw_cursor (GtkLabel  *label, gint xoffset, gint yoffset)
       cursor_location.width = 0;
       cursor_location.height = PANGO_PIXELS (cursor1->height);
 
-      gc = _gtk_get_insertion_cursor_gc (widget, TRUE);
-      _gtk_draw_insertion_cursor (widget, widget->window, gc,
-                                 &cursor_location, dir1,
-                                  dir2 != GTK_TEXT_DIR_NONE);
-      g_object_unref (gc);
+      gtk_draw_insertion_cursor (widget, widget->window, NULL,
+                                &cursor_location, TRUE, dir1,
+                                dir2 != GTK_TEXT_DIR_NONE);
       
       if (dir2 != GTK_TEXT_DIR_NONE)
        {
@@ -1779,10 +1776,9 @@ gtk_label_draw_cursor (GtkLabel  *label, gint xoffset, gint yoffset)
          cursor_location.width = 0;
          cursor_location.height = PANGO_PIXELS (cursor2->height);
 
-         gc = _gtk_get_insertion_cursor_gc (widget, FALSE);
-         _gtk_draw_insertion_cursor (widget, widget->window, gc,
-                                     &cursor_location, dir2, TRUE);
-         g_object_unref (gc);
+         gtk_draw_insertion_cursor (widget, widget->window, NULL,
+                                    &cursor_location, FALSE, dir2,
+                                    TRUE);
        }
     }
 }
index bbb5e6c212051f0ca66189087a6f8112fd061ce2..8ce713fcba31a2b722c7e199790eefd3a256fe9f 100644 (file)
@@ -132,6 +132,8 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
    * vice-versa, and when a buttton is moved from one group of 2 or
    * more buttons to a different one, but not when the composition
    * of the group that a button belongs to changes.
+   *
+   * Since: 2.4
    */
   group_changed_signal = g_signal_new ("group-changed",
                                       G_OBJECT_CLASS_TYPE (object_class),
index 771f0aca7518c7a0ce7aeb521d9b0532ac8e9f52..3913f42d3796bc3ff3c4a68a480da95b2eb5a5d6 100644 (file)
@@ -308,8 +308,10 @@ gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass)
    * to changes. This is emitted when a radio menu item switches from
    * being alone to being part of a group of 2 or more menu items, or
    * vice-versa, and when a buttton is moved from one group of 2 or
-   * more menu items to a different one, but not when the composition
+   * more menu items ton a different one, but not when the composition
    * of the group that a menu item belongs to changes.
+   *
+   * Since: 2.4
    */
   group_changed_signal = g_signal_new ("group-changed",
                                       G_OBJECT_CLASS_TYPE (object_class),
index f7794a7fa7af83046c20a1a8a675baff0f55061d..7626cb4587d28720a00c54ee671784cf55e7036e 100644 (file)
@@ -1398,7 +1398,7 @@ _gtk_rc_context_get_default_font_name (GtkSettings *settings)
        g_free (context->font_name);
        context->font_name = g_strdup (new_font_name);
  
-       _gtk_rc_reset_styles (settings);
+       gtk_rc_reset_styles (settings);
     }
           
   g_free (new_font_name);
index a0421a412e00a0f36dc591ba77fa48e4ee73c953..fab7e95bed29c209782aaed97755b2f7dc9c8c05 100644 (file)
@@ -594,9 +594,11 @@ gtk_settings_notify (GObject    *object,
     case PROP_XFT_DPI:
       pango_xft_substitute_changed (GDK_SCREEN_XDISPLAY (settings->screen),
                                    GDK_SCREEN_XNUMBER (settings->screen));
-      /* See comments with _gtk_rc_reset_styles for why this is a hack
+      /* This is a hack because with gtk_rc_reset_styles() doesn't get
+       * widgets with gtk_widget_style_set(), and also causes more
+       * recomputation than necessary.
        */
-      _gtk_rc_reset_styles (GTK_SETTINGS (object));
+      gtk_rc_reset_styles (GTK_SETTINGS (object));
       break;
 #endif /* GDK_WINDOWING_X11 */
     }
index e66e32f6dbad12898f3082d1e4aee4daab5714e4..212e8f74261928be0f618b9ed689f2dabfbff414 100644 (file)
@@ -654,6 +654,8 @@ gtk_style_class_init (GtkStyleClass *klass)
    * colormap and depth. Connecting to this signal is probably seldom
    * useful since most of the time applications and widgets only
    * deal with styles that have been already realized.
+   *
+   * Since: 2.4
    */
   realize_signal = g_signal_new ("realize",
                                 G_TYPE_FROM_CLASS (object_class),
@@ -670,6 +672,8 @@ gtk_style_class_init (GtkStyleClass *klass)
    * and depth are being cleaned up. A connection to this signal can be useful
    * if a widget wants to cache objects like a #GdkGC as object data on #GtkStyle.
    * This signal provides a convenient place to free such cached objects.
+   *
+   * Since: 2.4
    */
   unrealize_signal = g_signal_new ("unrealize",
                                   G_TYPE_FROM_CLASS (object_class),
@@ -6646,28 +6650,9 @@ make_cursor_gc (GtkWidget   *widget,
   return gtk_gc_get (widget->style->depth, widget->style->colormap, &gc_values, gc_values_mask);
 }
 
-/**
- * _gtk_get_insertion_cursor_gc:
- * @widget: a #GtkWidget
- * @is_primary: if the cursor should be the primary cursor color.
- * 
- * Get a GC suitable for drawing the primary or secondary text
- * cursor.
- *
- * Note: the return value is ref'ed because calls to this function
- *  on other widgets could result in this the GC being released
- *  which would be an unexpected side effect. If made public,
- *  this function should possibly be called create_insertion_cursor_gc().
- *
- * Return value: an appropriate #GdkGC. Call g_object_unref() on
- *   the gc when you are done with it; this GC may be shared with
- *   other users, so you must not modify the GC except for temporarily
- *   setting the clip before drawing with the GC, and then unsetting the clip
- *   again afterwards.
- **/
-GdkGC *
-_gtk_get_insertion_cursor_gc (GtkWidget *widget,
-                             gboolean   is_primary)
+static GdkGC *
+get_insertion_cursor_gc (GtkWidget *widget,
+                        gboolean   is_primary)
 {
   CursorInfo *cursor_info;
 
@@ -6709,7 +6694,7 @@ _gtk_get_insertion_cursor_gc (GtkWidget *widget,
                                                  "cursor-color",
                                                  &widget->style->black);
        
-      return g_object_ref (cursor_info->primary_gc);
+      return cursor_info->primary_gc;
     }
   else
     {
@@ -6720,31 +6705,17 @@ _gtk_get_insertion_cursor_gc (GtkWidget *widget,
                                                    "secondary-cursor-color",
                                                    &gray);
        
-      return g_object_ref (cursor_info->secondary_gc);
+      return cursor_info->secondary_gc;
     }
 }
 
-/**
- * _gtk_draw_insertion_cursor:
- * @widget: a #GtkWidget
- * @drawable: a #GdkDrawable
- * @gc: a #GdkGC
- * @location: location where to draw the cursor (@location->width is ignored)
- * @direction: whether the cursor is left-to-right or
- *             right-to-left. Should never be #GTK_TEXT_DIR_NONE
- * @draw_arrow: %TRUE to draw a directional arrow on the
- *        cursor. Should be %FALSE unless the cursor is split.
- * 
- * Draws a text caret on @drawable at @location. This is not a style function
- * but merely a convenience function for drawing the standard cursor shape.
- **/
-void
-_gtk_draw_insertion_cursor (GtkWidget        *widget,
-                           GdkDrawable      *drawable,
-                           GdkGC            *gc,
-                           GdkRectangle     *location,
-                            GtkTextDirection  direction,
-                            gboolean          draw_arrow)
+static void
+draw_insertion_cursor (GtkWidget        *widget,
+                      GdkDrawable      *drawable,
+                      GdkGC            *gc,
+                      GdkRectangle     *location,
+                      GtkTextDirection  direction,
+                      gboolean          draw_arrow)
 {
   gint stem_width;
   gint arrow_width;
@@ -6801,3 +6772,48 @@ _gtk_draw_insertion_cursor (GtkWidget        *widget,
         }
     }
 }
+
+/**
+ * gtk_draw_insertion_cursor:
+ * @widget:  a #GtkWidget
+ * @drawable: a #GdkDrawable 
+ * @area: rectangle to which the output is clipped, or %NULL if the
+ *        output should not be clipped
+ * @location: location where to draw the cursor (@location->width is ignored)
+ * @is_primary: if the cursor should be the primary cursor color.
+ * @direction: whether the cursor is left-to-right or
+ *             right-to-left. Should never be #GTK_TEXT_DIR_NONE
+ * @draw_arrow: %TRUE to draw a directional arrow on the
+ *        cursor. Should be %FALSE unless the cursor is split.
+ * 
+ * Draws a text caret on @drawable at @location. This is not a style function
+ * but merely a convenience function for drawing the standard cursor shape.
+ *
+ * Since: 2.4
+ **/
+void
+gtk_draw_insertion_cursor (GtkWidget        *widget,
+                          GdkDrawable      *drawable,
+                          GdkRectangle     *area,
+                          GdkRectangle     *location,
+                          gboolean          is_primary,
+                          GtkTextDirection  direction,
+                          gboolean          draw_arrow)
+{
+  GdkGC *gc;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (GDK_IS_DRAWABLE (drawable));
+  g_return_if_fail (location != NULL);
+  g_return_if_fail (direction != GTK_TEXT_DIR_NONE);
+
+  gc = get_insertion_cursor_gc (widget, is_primary);
+  if (area)
+    gdk_gc_set_clip_rectangle (gc, area);
+  
+  draw_insertion_cursor (widget, drawable, gc,
+                        location, direction, draw_arrow);
+  
+  if (area)
+    gdk_gc_set_clip_rectangle (gc, NULL);
+}
index cc6ac74aa7b6c06f2f7d00e55a9ee2a992a1a157..80e9a12196b54f021e962dc21039a7f04713e6ba 100644 (file)
@@ -885,14 +885,13 @@ void gtk_paint_string     (GtkStyle        *style,
                           const gchar     *string);
 #endif /* GTK_DISABLE_DEPRECATED */
 
-GdkGC *_gtk_get_insertion_cursor_gc (GtkWidget        *widget,
-                                    gboolean          is_primary);
-void   _gtk_draw_insertion_cursor   (GtkWidget        *widget,
-                                    GdkDrawable      *drawable,
-                                    GdkGC            *gc,
-                                    GdkRectangle     *location,
-                                    GtkTextDirection  direction,
-                                    gboolean          draw_arrow);
+void   gtk_draw_insertion_cursor (GtkWidget        *widget,
+                                 GdkDrawable      *drawable,
+                                 GdkRectangle     *area,
+                                 GdkRectangle     *location,
+                                 gboolean          is_primary,
+                                 GtkTextDirection  direction,
+                                 gboolean          draw_arrow);
 
 #ifdef __cplusplus
 }
index 55e64099fbe3795187fe7a0d2958dda29e5632ab..f5937298bea9823bf32a45d3cd5b2e0cdd6d0dc3 100644 (file)
@@ -821,7 +821,6 @@ gtk_text_layout_draw (GtkTextLayout *layout,
               GtkTextCursorDisplay *cursor = cursor_list->data;
              GtkTextDirection dir;
              GdkRectangle cursor_location;
-              GdkGC *gc;
 
               dir = line_display->direction;
              if (have_strong && have_weak)
@@ -834,14 +833,10 @@ gtk_text_layout_draw (GtkTextLayout *layout,
              cursor_location.y = current_y + line_display->top_margin + cursor->y;
              cursor_location.width = 0;
              cursor_location.height = cursor->height;
-             gc = _gtk_get_insertion_cursor_gc (widget, cursor->is_strong);
-             gdk_gc_set_clip_rectangle(gc, &clip);
-             _gtk_draw_insertion_cursor (widget, drawable, gc, &cursor_location,
-                                          dir, have_strong && have_weak);
-              gdk_gc_set_clip_rectangle (gc, NULL);
 
-             g_object_unref (gc);
+             gtk_draw_insertion_cursor (widget, drawable, &clip, &cursor_location,
+                                        cursor->is_strong,
+                                        dir, have_strong && have_weak);
 
               cursor_list = cursor_list->next;
             }